<template>
	<view class="container">
		<view class="list">
			<view class="item" v-for="(item,i) in list" :key="item.id" @click="toDetail(item)">
				<view class="info">
					<image :src="$img_base_url(item.orderDetail.image)" mode="aspectFill"></image>
					<view class="r-box">
						<view class="l-1">
							<view class="name one-row">
								{{item.orderDetail.name}}
							</view>
							<view class="num">
								剩余次数：{{item.orderDetail.num}}次
							</view>
						</view>
						<view class="l-2">
							规格名称规格名称10次
						</view>
						<view class="l-3" v-if="">
							服务时间：每周三、五 13：00
						</view>
						<view class="l-4">
							服务者：张三师傅
						</view>
					</view>
				</view>
				<view class="btn">
					<button @click.stop="contact()">联系服务者</button>
					<button @click.stop="appointment()">预约下单</button>
				</view>
			</view>
		</view>
		
		<popupBox ref="tip" :isSlot="true">
			<view class="con-box">
				<view class="title">
					提示
				</view>
				<view class="text">
					您预定的定死医护服务包名称 <text>30</text> 分钟后将按你预定的时间和服务人员进行下单，请问是否正常下单呢?
				</view>
				<view class="btn">
					<button class="pause">本次暂停</button>
					<button class="confirm">正常下单</button>
				</view>
			</view>
		</popupBox>
	</view>
</template>

<script>
	import { userFwb } from '@/utils/api/serviceApi.js'
	import popupBox from '../../../components/popup/popup.vue';
	export default {
		components:{
			popupBox
		},
		data() {
			return {
				page:1,
				list:[]
			};
		},
		onShow() {
			// this.$refs.tip.open()
			this.getuserFwb()
		},
		methods:{
			// 联系服务者
			contact(){
				uni.makePhoneCall({
					phoneNumber: '18888888888'
				});
			},
			// 预约下单
			appointment(){
				console.log(123)
				uni.navigateTo({
					url:'/pagesMine/servicePackage/confirmOrder/confirmOrder'
				})	
			},
			// 获取服务包
			getuserFwb(){
				uni.showLoading({
					title:'加载中...'
				})
				userFwb({page:this.page}).then(res=>{
					uni.hideLoading()
					if(this.page==1){
						this.list = res.data
					}else{
						this.list = [...res.data,...this.list]
					}
				})
			},
			
			toDetail(data){
				uni.navigateTo({
					url:`/pagesMine/servicePackage/detail/detail?data=${JSON.stringify(data)}`
				})
			},
		},
		onReachBottom() {
			this.page++
			this.getuserFwb()
		}
	}
</script>

<style lang="scss" scoped>
.container{
	padding: 0 22rpx;
	box-sizing: border-box;
	.list{
		.item{
			margin-top: 20rpx;
			padding: 20rpx 20rpx 30rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 20rpx;
			.info{
				display: flex;
				&>image{
					width: 180rpx;
					height: 180rpx;
				}
				.r-box{
					width: calc(100% - 180rpx);
					padding-left: 20rpx;
					box-sizing: border-box;
					.l-1{
						display: flex;
						align-items: flex-end;
						justify-content: space-between;
						.name{
							width: 55%;
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;
							line-height: 44rpx;
						}
						.num{
							font-weight: bold;
							font-size: 28rpx;
							color: #E72A2A;
							line-height: 40rpx;
						}
					}
					.l-2{
						font-weight: bold;
						font-size: 24rpx;
						color: #999999;
						line-height: 34rpx;
						margin-top: 8rpx;
					}
					.l-3{
						font-weight: 400;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
						margin-top: 6rpx;
					}
					.l-4{
						font-weight: 400;
						font-size: 28rpx;
						color: #333333;
						line-height: 40rpx;
						margin-top: 8rpx;
					}
				}
			}
			.btn{
				padding-top: 30rpx;
				display: flex;
				justify-content: flex-end;
				button{
					width: 242rpx;
					height: 80rpx;
					background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
					border-radius: 80rpx;
					font-weight: bold;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 80rpx;
				}
				button + button{
					margin-left: 20rpx;
				}
			}
		}
	}
}


.con-box{
	width: 596rpx;
	background: #FFFFFF;
	border-radius: 16rpx;
	padding: 0 22rpx;
	box-sizing: border-box;
	background-color: #FFFFFF;
	.title{
		padding-top: 42rpx;
		font-weight: bold;
		font-size: 34rpx;
		color: #000000;
		line-height: 48rpx;
		text-align: center;
	}
	.text{
		font-weight: 400;
		font-size: 32rpx;
		color: #333333;
		line-height: 44rpx;
		margin-top: 20rpx;
		text-align: center;
		text{
			color: #E72A2A;
		}
	}
	.btn{
		padding: 40rpx 12rpx 38rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		button{
			width: 242rpx;
			height: 80rpx;
			border-radius: 80rpx;
			font-weight: bold;
			font-size: 32rpx;
			line-height: 80rpx;
			&.pause{
				background: #F8F8F8;
				color: #999999;
			}
			&.confirm{
				background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
				color: #FFFFFF;
			}
		}
	}
}
</style>
